<?php

namespace App\Http\Controllers\OA;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Logic\LoginLogic;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    //登录页面
    public function login()
    {
        dd(base64_encode(env('APP_KEY')));
    }

    //验证login
    public function checkLogin(Request $request)
    {
        $rules = [
            'account'=>'required|string',
            'password'=>'required|string',
            'is_company'=>'required|in:0,1'
        ];

        $this->verify(
            $request->all(),
            $rules,
            [
                'account.required'=>'账号不能为空',
                'password.required'=>'密码不能为空',
                'is_company.required'=>'是否是公司不能为空',
            ]);

        try{
            $logic = new LoginLogic();
            $result = $logic->verifyLogin($request->all());

           //session(['userinfo'=>$result]);

            ret_json('ok','ok',$result);

        }catch(\Exception $e){
            ret_json('err',$e->getMessage());
        }

    }
}
